home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / tool-inc.zip / GETENV.INC < prev    next >
Text File  |  1989-06-02  |  1KB  |  73 lines

  1.  
  2. (*
  3.  * Copyright 1987, 1989 Samuel H. Smith;  All rights reserved
  4.  *
  5.  * This is a component of the ProDoor System.
  6.  * Do not distribute modified versions without my permission.
  7.  * Do not remove or alter this notice or any other copyright notice.
  8.  * If you use this in your own program you must distribute source code.
  9.  * Do not use any of this in a commercial product.
  10.  *
  11.  *)
  12.  
  13. (*
  14.  * get the value of an environment variable
  15.  *
  16.  * example:  path := get_environment_var('PATH=');
  17.  *
  18.  *)
  19.  
  20. function get_environment_var(id: string20): anystring;
  21.  
  22.  
  23. {$IFDEF TP40}
  24. var
  25.    envseg:  integer;
  26.    i:       integer;
  27.    env:     anystring;
  28.  
  29. begin
  30.    envseg := memw[PrefixSeg:$2c];
  31.    i := 0;
  32.  
  33.    repeat
  34.       env := '';
  35.       while mem[envseg:i] <> 0 do
  36.       begin
  37.          env := env + chr(mem[envseg:i]);
  38.          inc(i);
  39.       end;
  40.  
  41.       if copy(env,1,length(id)) = id then
  42.       begin
  43.          get_environment_var := copy(env,length(id)+1,255);
  44.          exit;
  45.       end;
  46.  
  47.       inc(i);
  48.    until mem[envseg:i] = 0;
  49.  
  50. (* not found *)
  51.    get_environment_var := '';
  52. end;
  53.  
  54. {$ELSE}  {TP 5.0}
  55.  
  56. begin
  57.    dec(id[0]);    {delete trailing =}
  58.    get_environment_var := GetEnv(id);
  59. end;
  60.  
  61. {$ENDIF}
  62.  
  63.  
  64. function environment_on(id: string20): boolean;
  65. var
  66.    value:   string20;
  67. begin
  68.    value := GetEnv(id);
  69.    stoupper(value);
  70.    environment_on := (value = 'ON');
  71. end;
  72.  
  73.